<?php

namespace Part15_AbstractFactoryPattern\Code4;

class DataAccess
{
    // 写死在此处或者读取配置项
    private static $db = 'mysql';

    public static function createUser()
    {
        switch (self::$db) {
            case 'sqlserver':
                return new SqlServerUser();
            case 'mysql':
                return new MysqlUser();
            default:
                return null;
        }
    }

    public static function createDepartment()
    {
        switch (self::$db) {
            case 'sqlserver':
                return new SqlServerDepartment();
            case 'mysql':
                return new MysqlDepartment();
            default:
                return null;
        }
    }
}